package com.dmj.sqldsl.builder;

import com.dmj.sqldsl.builder.config.EntityConfig;
import com.dmj.sqldsl.builder.config.GlobalConfig;
import com.dmj.sqldsl.model.DslInsert;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;

@AllArgsConstructor(access = AccessLevel.PROTECTED)
public class InsertSelectBuilder<T> {

  private final InsertBuilder<T> insertBuilder;

  private final DslQueryBuilder queryBuilder;


  private DslInsert toInsert(EntityConfig config) {
    return DslInsert.builder()
        .table(insertBuilder.getEntityBuilder().buildTable(config))
        .query(queryBuilder.toQuery(config))
        .build();
  }

  public DslInsert toInsert() {
    return this.toInsert(GlobalConfig.getEntityConfig());
  }
}
